package collisions;

import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.collision.BasicCollisionGroup;

import sprites.TDEntity;
import sprites.Enemy;

/**
 * Deals with the collision between an enemy and a tower.
 * 
 * @author Alex Lee (hl69)
 */
public class EnemyTowerCollision extends BasicCollisionGroup
{

	@Override
	public void collided(Sprite s1, Sprite s2)
	{
		Enemy enemy = (Enemy)s1;
		TDEntity tower = (TDEntity)s2;
		
		/*
		 * The enemy can no longer move.
		 */
		enemy.setStatus(enemy.STOPPED);
		
		/*
		 * The enemy deals damage to the tower. If the tower is sufficiently
		 * damaged, it will be destroyed.
		 */
		if(tower.damage(enemy.getDamage()) <= 0)
		{
			tower.kill();
			tower.setActive(false);
			enemy.setStatus(enemy.MOVING);
		}
	}

}
